package com.hujf.flink.DataSet;

import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.apache.flink.api.java.aggregation.Aggregations;
import org.apache.flink.api.java.operators.AggregateOperator;
import org.apache.flink.api.java.tuple.Tuple3;

/**
 * @Author hujf
 * @Date 2022/5/19 9:23
 * @Description TODO
 */
public class AggregateTest {
    public static void main(String[] args) throws Exception {
        ExecutionEnvironment environment = ExecutionEnvironment.getExecutionEnvironment();

        DataSet<Tuple3<Integer, Integer, Integer>> tuple2DataSource = environment.fromElements(new Tuple3<>(1,2,3), new Tuple3<>(2, 3,4),new Tuple3<>(1,2,2));

        AggregateOperator<Tuple3<Integer, Integer, Integer>> and = tuple2DataSource.groupBy(1).aggregate(Aggregations.SUM, 0)
                .and(Aggregations.MIN, 2);

        and.print();
    }
}
